<template>
	<view @touchmove.stop = "">
		<view class="fail">
			<image class="img" :src="image"></image>
			<text class="text">请求超时噢，查看一下网络是否正常</text>
			<view class="but" @click="refresh">重试</view>
		</view>
	</view>
</template>

<script>
	let image = '';
	export default {
		data() {
			return {
				image:image,
			};
		},
		props:{
			tabbar:{
				type:Boolean,
				default:false
			},
		},
		methods:{
			refresh(){
				let pages = getCurrentPages(); // 当前页面
				let beforePage = pages[pages.length - 1];
	
				var partKeys = Object.keys(beforePage.options);
				var partValues = Object.values(beforePage.options);
				let url=beforePage.route;
				for(let i=0;i<partKeys.length;i++){
					if(i==0){
						url+='?'
					}else{
						url+='&&'
					}
					url+=partKeys[i]+'='+partValues[i]
				}
				
				if(this.tabbar){
					uni.switchTab({
						url:'/'+url,
						success: function (e) { 
						      beforePage.onLoad();
						    } 
					})
					console.log('/'+url)
				}else{
					uni.redirectTo({
						url:'/'+url,
					})
				}
			}
		}
	}
</script>

<style scoped>
.fail{
	position: fixed;
	top: 0;
	left: 0;
	z-index: 10080;
	background-color: #fff;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
}
.fail .img{
	width: 300rpx;
	height: 220rpx;
}
.fail .text{
	color: #c0c4cc;
}
.fail .but{
	border: 1px solid #c0c4cc;
	padding:5rpx 20rpx;
	margin-top: 20rpx;
	border-radius: 10rpx;
}
</style>
